from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView

from goods.models import SpecificationOption, SPUSpecification
from meiduo_admin.serializers.specOptionSerializer import SpecOptionSerializer, SpecShowSerializer
from meiduo_admin.utils import PaginatorShow
from meiduo_admin.permissions import *


class SpecOptionView(ModelViewSet):
    queryset = SpecificationOption.objects.all().order_by("id")
    serializer_class = SpecOptionSerializer
    permission_classes = [IsAdminUser]

    pagination_class = PaginatorShow


class SpecNameView(ListAPIView):
    queryset = SPUSpecification.objects.all()
    serializer_class = SpecShowSerializer
    permission_classes = [IsAdminUser]